Skip to content

fix(desktop): surface invite creation errors separately from clipboard failures - #3691

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/surface-invite-creation-errors-3636
Open

fix(desktop): surface invite creation errors separately from clipboard failures#3691
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/surface-invite-creation-errors-3636

Conversation

@iroiro147

Copy link
Copy Markdown

Problem

When creating an invite link failed (e.g. CORS preflight rejected, 403 Forbidden, network timeout), the user saw "Couldn't copy the invite link. Try again." — misattributing a server/network error to the clipboard. This was actively misleading: the clipboard worked fine elsewhere in the app, but the error message sent users looking at Tauri clipboard permissions instead of the network.

Closes #3636 (desktop part)

Root Cause

handleCopy in InviteLinkSection.tsx wrapped both mintInvite and writeTextToClipboard in a single try/catch. Any failure from either call produced the same generic "couldn't copy" toast, discarding the actual error message from the relay.

invitePost already throws a useful Error — either the server's json.error string or HTTP <status> — but that message was being swallowed.

Solution

Split the single try/catch into two:

Failure Old message New message
mintInvite fails "Couldn't copy the invite link. Try again." "Couldn't create the invite: <error.message>"
writeTextToClipboard fails (same) "Invite created, but copying to the clipboard failed."

The second message is materially different: because relay_invites stores only token_hash, an invite whose code fails to reach the clipboard is unrecoverable. Telling the user it was created but not copied is different from telling them to just try again.

Test Plan

cd desktop
node --test src/features/community-members/ui/inviteLinkErrorSeparation.test.mjs

All 6 tests pass:

  • both succeed: copies invite and shows success toast
  • mintInvite fails: shows creation error, does not attempt clipboard
  • clipboard fails: shows clipboard-specific error, invite was created
  • mintInvite error message is surfaced to the user
  • non-Error thrown by mintInvite produces generic message
  • copying status is set during operation

…d failures

The invite link copy handler wrapped both mintInvite and
writeTextToClipboard in a single try/catch. When mintInvite failed
(e.g. CORS preflight rejected, 403 Forbidden), the user saw
"Couldn't copy the invite link" — misattributing a server/network
error to the clipboard.

This separates the two failure modes:
- mintInvite failure: "Couldn't create the invite: <error message>"
  The error from invitePost (which includes the relay's json.error
  or HTTP status) is now surfaced to the user.
- clipboard failure: "Invite created, but copying to the clipboard
  failed." — distinct message acknowledging the invite was minted
  but copying failed (important because relay_invites stores only
  token_hash, so the code is unrecoverable).

Closes block#3636
@iroiro147
iroiro147 requested a review from a team as a code owner July 30, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A rejected CORS preflight is invisible on both sides: no relay log at any level, and the desktop reports it as a clipboard failure

1 participant